package com.travel.model.entity.content;

import com.travel.model.entity.auth.User;
import com.travel.model.entity.service.Destination;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;

@Data
@Entity
@Table(name = "travel_guides")
@EntityListeners(AuditingEntityListener.class)
@Schema(description = "旅游指南实体")
public class TravelGuide {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Schema(description = "指南ID")
    private Long id;

    @Schema(description = "指南标题")
    @Column(nullable = false)
    private String title;

    @Schema(description = "指南内容")
    @Column(columnDefinition = "TEXT")
    private String content;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    private User user;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "destination_id")
    private Destination destination;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(
        name = "guide_tags",
        joinColumns = @JoinColumn(name = "guide_id"),
        inverseJoinColumns = @JoinColumn(name = "tag_id")
    )
    private Set<Tag> tags = new HashSet<>();

    @Schema(description = "指南状态(1:已发布 0:草稿)")
    private Integer status = 1;

    @CreatedDate
    @Schema(description = "创建时间")
    @Column(name = "created_time")
    private LocalDateTime createdTime;

    @LastModifiedDate
    @Schema(description = "更新时间")
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;
} 